package com.hxy.manager.activity.bill;

import android.app.Activity;
import android.os.Bundle;
import android.widget.BaseAdapter;
import android.widget.ListView;

import com.hxy.manager.R;

public class BillIn extends Activity {
	ListView listView;
	private BaseAdapter listViewAdapter;
	    //当前选择
	private int selecteItem=0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.store);
        getActionBar().setDisplayHomeAsUpEnabled(true);//向上返回
        listView =(ListView)findViewById(R.id.listViewBillIn);
       // loadBillIn();
       
    }   /*
    void loadBillIn(){



        //获取所有通讯录联系人
        MakeTable ct = new MakeTable(this);
        users = ct.getAllData();
     
        并没有解决逆序
        for (int start = 0, end = users.length - 1; start < end; start++, end--) {
            LeiXing temp = users[end];
            users[end] = users[start];
            users[start] = temp;
        }

        //listView列表实现适配器
        listViewAdapter = new BaseAdapter() {



            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
/*
                //逆序的实现，貌似会带来listView的卡顿。position是listview的位置。position2是的数据库的位置
                int position2= users.length-1-position;

                //加入,这个类是自定义的静态类。
                ViewHolder holder;

                if(convertView==null){
                    
                    TextView textView= new TextView(Store.this);
                    textView.setTextSize(22);
                    convertView=textView;
                    

                    final LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    convertView = inflater.inflate(R.layout.item,null);
                    holder = new ViewHolder();
                    holder.icon=(ImageView)convertView.findViewById(R.id.imageView);
                    holder.name=(TextView)convertView.findViewById(R.id.nameView);
                    holder.price=(TextView)convertView.findViewById(R.id.priceView);
                    convertView.setTag(holder);

                }
                else {
                    holder=(ViewHolder)convertView.getTag();
                }



                /************************三元运算符****************************
         //       String price = users[position].getPrice()==null?"":users[position].getPrice();
       //         ((TextView)convertView).setText(""+users[position].getName()+"\n      "+position+"价格:  "+price);
        //        ((TextView)convertView).setText((position+1)+".书名："+users[position].getName()+"\n    "+"价格:  "+price);


                holder.icon.setImageResource(R.drawable.store);
                holder.name.setText(users[position2].getName());
                holder.price.setText(users[position2].getPrice());

               // position是listview的位置。
                if(position==selecteItem){
                    convertView.setBackgroundColor(0x5f1296db);
                    //	Toast.makeText(this, "text", Toast.LENGTH_LONG).show();
                }
                else{
                    convertView.setBackgroundColor(0);
                }
                return convertView;
            }

            @Override
            public long getItemId(int position) {
                // TODO Auto-generated method stub
                return position;
            }

            @Override
            public Object getItem(int position) {
                // TODO Auto-generated method stub
                return users[position];
            }

            @Override
            public int getCount() {
                // TODO Auto-generated method stub
                return users.length;
            }
        };
        //设置listView控件的适配器
        listView.setAdapter(listViewAdapter);
        //长按
        listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

                                                @Override
                                                public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                                                                               int arg2, long arg3) {
                                                    // TODO Auto-generated method stub
                                                    selecteItem=arg2;
                                                    //逆序的实现，貌似会带来listView的卡顿。
                                                    int selecteItem2= users.length-1-selecteItem;
                                                  //  Toast.makeText(Store.this,"长按修改",Toast.LENGTH_SHORT).show();
                                                    if(users[selecteItem2].getNumber()!=null){
                                                        Intent intent3 = new Intent(Store.this,Update.class);
                                                        intent3.putExtra("scanCode", users[selecteItem2].getNumber());
                                                        startActivity(intent3);
                                                    }
                                                   else {
                                                        Toast.makeText(Store.this, "没有数据",Toast.LENGTH_SHORT).show();
                                                   }

                                                    return true;

                                                }
                                            }
        );
        //短按
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                                    long arg3) {
                // TODO Auto-generated method stub
				/*
				//记录单击列的位置
				selecteItem=arg2;
				//刷新列表
				listViewAdapter.notifyDataSetChanged();
				

                selecteItem=arg2;
                //逆序的实现，貌似会带来listView的卡顿。
                int selecteItem2= users.length-1-selecteItem;

                if(users[selecteItem2].getNumber()!=null){
                    Intent intent3 = new Intent(Store.this,Show.class);
                    intent3.putExtra("scanCode", users[selecteItem2].getNumber());
                    startActivity(intent3);
                }
                else {
                    Toast.makeText(Store.this, "空",Toast.LENGTH_SHORT).show();
                }


            }

        });


    
    	
    	
    }
*/
}
